home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / fix101ky.zip / FIX101KY.ASM < prev    next >
Assembly Source File  |  1988-07-24  |  5KB  |  124 lines

  1. ;  Copyright (c) 1988  Thomas G. Hanlin III
  2. ;  FIX101KY.ASM
  3. ;  remaps the 101-key "enhanced" keyboard to a semblence of sanity
  4. ;  initial version, 07/24/88
  5.  
  6.  
  7. ResLength equ Install - Main + 256
  8.  
  9.  
  10. Sseg          segment byte stack 'prog'    ; dummy stack segment
  11. Sseg          ends
  12.  
  13.  
  14. Cseg          segment byte public 'prog'
  15.               assume  cs:Cseg, ds:Cseg, ss:Sseg
  16.  
  17.               org     100h
  18.  
  19.  
  20. Main          proc    far
  21.               jmp     Install
  22. Main          endp
  23.  
  24.  
  25.  
  26. Intrpt        proc    far
  27.               cmp     ah,4Fh             ; do we need to worry about it?
  28.               jne     OrigHandler        ;   no, let old handler take it
  29.  
  30.               cmp     al,38h             ; Alt make code?
  31.               je      mAlt               ;   yes
  32.               cmp     al,0B8h            ; Alt break code?
  33.               je      bAlt               ;   yes
  34.  
  35.               cmp     al,3Ah             ; CapsLock make code?
  36.               je      mCapsLock          ;   yes
  37.               cmp     al,0BAh            ; CapsLock break code?
  38.               je      bCapsLock          ;   yes
  39.  
  40.               cmp     al,1Dh             ; Control make code?
  41.               je      mControl           ;   yes
  42.               cmp     al,9Dh             ; Control break code?
  43.               je      bControl           ;   yes
  44.  
  45.               cmp     al,1               ; Esc make code?
  46.               je      mEsc               ;   yes
  47.               cmp     al,81h             ; Esc break code?
  48.               je      bEsc               ;   yes
  49.  
  50.               cmp     al,29h             ; Tilde make code?
  51.               je      mTilde             ;   yes
  52.               cmp     al,0A9h            ; Tilde break code?
  53.               je      bTilde             ;   yes
  54.  
  55. OrigHandler:  stc                        ; give it to original kbd handler
  56.  
  57.               db 0EAh      ; self-modifying code: JMP FAR PTR xxxx:yyyy
  58.       VOFS    dw ?         ; original INT 15h vector ("misc system services")
  59.       VSEG    dw ?
  60.  
  61. mAlt:         mov     al,3Ah             ; xlate to CapsLock key "make" code
  62.               jmp     OrigHandler
  63. bAlt:         mov     al,0BAh            ; xlate to CapsLock key "break" code
  64.               jmp     OrigHandler
  65.  
  66. mCapsLock:    mov     al,1Dh             ; xlate to control key "make" code
  67.               jmp     OrigHandler
  68. bCapsLock:    mov     al,9Dh             ; xlate to control key "break" code
  69.               jmp     OrigHandler
  70.  
  71. mControl:     mov     al,38h             ; xlate to alt key "make" code
  72.               jmp     OrigHandler
  73. bControl:     mov     al,0B8h            ; xlate to alt key "break" code
  74.               jmp     OrigHandler
  75.  
  76. mEsc:         mov     al,29h             ; xlate to ~` "make" code
  77.               jmp     OrigHandler
  78. bEsc:         mov     al,0A9h            ; xlate to ~` "break" code
  79.               jmp     OrigHandler
  80.  
  81. mTilde:       mov     al,1               ; xlate to <ESC> "make" code
  82.               jmp     OrigHandler
  83. bTilde:       mov     al,81h             ; xlate to <ESC> "break" code
  84.               jmp     OrigHandler
  85. Intrpt        endp
  86.  
  87.  
  88.  
  89. Install       proc    near
  90.               mov     dx,offset Msg      ; display copyright/header message
  91.               mov     ah,9
  92.               int     21h
  93.               xor     ax,ax
  94.               mov     es,ax
  95.               and     byte ptr es:[0417h],0DFh ; turn off NumLock
  96.               mov     es,ds:[002Ch]
  97.               mov     ah,49h             ; free up our copy of the environment
  98.               int     21h
  99.               mov     ax,3515h           ; get vector for INT 15h
  100.               int     21h
  101.               mov     VOFS,bx            ; save it away
  102.               mov     VSEG,es            ; (self-modifying code)
  103.               mov     dx,offset Intrpt
  104.               mov     ax,2515h           ; install our keyboard preprocessor
  105.               int     21h
  106.               mov     dx,ResLength       ; size of our interrupt handler
  107.               test    dl,0Fh             ; see if it's on a paragraph boundary
  108.               sahf                       ; save results
  109.               mov     cl,4
  110.               shr     dx,cl              ; convert bytes to paragraphs
  111.               lahf                       ; paragraph-aligned?
  112.               jz      GoTSR              ;   yes, we're done
  113.               inc     dx                 ; round up to next paragraph
  114. GoTSR:        mov     ax,3100h           ; terminate and stay resident
  115.               int     21h
  116. Install       endp
  117.  
  118. Msg db "Copyright (c) 1988  Thomas G. Hanlin III",13,10
  119.     db 'FIX101KY: remap 101-key "enhanced" keyboard'
  120.     db 13,10,"$"
  121.  
  122. Cseg          ends
  123.               end            Main
  124.